package com.zmn.oms.dubbo.impl.normal.master;


import com.zmn.common.dto2.ResponseDTO;
import com.zmn.common.utils.reflect.BeanMapper;
import com.zmn.oms.common.dro.normal.master.MasterWorkingDRO;
import com.zmn.oms.dubbo.interfaces.normal.master.MasterWorkingListRemoteService;
import com.zmn.oms.dubbo.utils.DubboConsts;
import com.zmn.oms.model.entity.masterworking.MasterWorking;
import com.zmn.oms.services.interfaces.masterworking.MasterWorkingService;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;


/**
 * 类描述：
 *
 * @author ligang
 * @since 2021/12/7 16:26
 */
@Slf4j
@Service(loadbalance = "roundrobin", timeout = 10000, retries = 2, version = DubboConsts.INTERFACE_VERSION, validation = "true")
public class MasterWorkingListRemoteServiceImpl implements MasterWorkingListRemoteService {

    @Autowired
    private MasterWorkingService masterWorkingService;

    @Override
    public ResponseDTO<MasterWorkingDRO> getMasterWorkingByWorkId(Long workId) {
        log.debug("查询工程师进行中的工单入参：【{}】", workId);
        try {
            MasterWorking masterWorking = masterWorkingService.findMasterWorkingByWorkId(workId);
            MasterWorkingDRO masterWorkingDRO = BeanMapper.map(masterWorking, MasterWorkingDRO.class);
            return ResponseDTO.success(masterWorkingDRO);
        } catch (Exception e) {
            return ResponseDTO.fail(e.getMessage());
        }
    }
}
